//
//  NewAddressCell.m
//  pmmSS
//
//  Created by Mac book on 2017/9/21.
//  Copyright © 2017年 WTFSSD. All rights reserved.
//

#import "NewAddressCell.h"

@interface NewAddressCell()

@property (nonatomic,strong) UILabel *name_label,*phonrNum_label,*address_label;
@property (nonatomic,strong) UIButton *edit_button,*clear_button;

@end

@implementation NewAddressCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self initSubViews];
    }

    return  self;
}

-(void)initSubViews{

    WeakSelf(weakSelf);


    // TODO: 订单号
    _name_label  = [HMLabel createLabelWithText:@"李明明" andTextColor:[UIColor blackColor] andBgColor:nil andFont:[UIFont fontWithName:default_fontname size:autoScaleW(16)] andTextAlignment:NSTextAlignmentLeft];

    [self.contentView addSubview:_name_label];

    [_name_label mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(autoScaleH(10));
        make.left.mas_equalTo(autoScaleW(15));

        make.height.mas_equalTo(autoScaleH(22));

        make.width.mas_equalTo(autoScaleW(60));
        
    }];

    // TODO: 订单号
    _phonrNum_label  = [HMLabel createLabelWithText:@"13566889977" andTextColor:[UIColor blackColor] andBgColor:nil andFont:[UIFont fontWithName:default_fontname size:autoScaleW(15)] andTextAlignment:NSTextAlignmentRight];

    [self.contentView addSubview:_phonrNum_label];

    [_phonrNum_label mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(autoScaleH(10));
        make.right.mas_equalTo(autoScaleW(-15));

        make.height.mas_equalTo(autoScaleH(22));

        make.width.mas_equalTo(autoScaleW(150));
        
    }];

    _address_label  = [HMLabel createLabelWithText:@"湖北省武汉市江汉区泛海SOLO中心 CBD中心大厦东侧 武汉中心钢材市场" andTextColor:RGBA(51,51,51,1) andBgColor:nil andFont:[UIFont fontWithName:default_fontname size:autoScaleW(14)] andTextAlignment:NSTextAlignmentLeft];
    _address_label.numberOfLines = 2;

    [self.contentView addSubview:_address_label];

    [_address_label mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(weakSelf.name_label.mas_bottom).offset(autoScaleH(5));
        make.left.mas_equalTo(autoScaleW(15));

        make.height.mas_equalTo(autoScaleH(40));

        make.right.mas_equalTo(autoScaleW(-25));
        
    }];

    UIView *lineView = [[UIView alloc]init];

    lineView.backgroundColor = View_BackgroundColor;
    [self.contentView addSubview:lineView];


    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(weakSelf.address_label.mas_bottom).offset(autoScaleH(5));
        make.height.mas_equalTo(autoScaleH(0.5));
        make.left.mas_equalTo(autoScaleW(0));
        make.right.mas_equalTo(autoScaleW(0));
        
    }];

    _clear_button = [HMButton createButtonWithTitle:@"删除" andTitleColor:RGBA(51, 51, 51, 1) andBgColor:[UIColor yellowColor] andImage:[UIImage imageNamed:@"clear_address"] andBgImage:nil andSelecter:@selector(clickButton:) andTarget:self andTag:101];

    _clear_button.titleLabel.font = [UIFont fontWithName:default_fontname size:autoScaleW(12)];


     [_clear_button setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, autoScaleW(30))];
    [self.contentView addSubview:_clear_button];

    [_clear_button mas_makeConstraints:^(MASConstraintMaker *make) {

        make.bottom.mas_equalTo(autoScaleH(-3));
        make.right.mas_equalTo(autoScaleW(-10));
        make.width.mas_equalTo(autoScaleW(55));
        make.height.mas_equalTo(autoScaleH(27));

    }];

    _edit_button = [HMButton createButtonWithTitle:@"编辑" andTitleColor:RGBA(51, 51, 51, 1) andBgColor:[UIColor yellowColor] andImage:[UIImage imageNamed:@"edit_address"] andBgImage:nil andSelecter:@selector(clickButton:) andTarget:self andTag:102];


    _edit_button.titleLabel.font = [UIFont fontWithName:default_fontname size:autoScaleW(12)];


    [_edit_button setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, autoScaleW(30))];

    [self.contentView addSubview:_edit_button];

    [_edit_button mas_makeConstraints:^(MASConstraintMaker *make) {

        make.bottom.mas_equalTo(autoScaleH(-3));
        make.right.mas_equalTo(weakSelf.clear_button.mas_left).offset(autoScaleW(-10));
        make.width.mas_equalTo(autoScaleW(55));
        make.height.mas_equalTo(autoScaleH(27));
        
    }];


}

-(void)clickButton:(UIButton *)button{

    [self.delegate passButtonTag:button.tag];

}



@end
